{% load wagtailimages_tags wagtailadmin_tags %}
{% load i18n l10n %}
{% if images %}
    {% if is_searching %}
        <h2 role="alert">
            {% blocktrans trimmed count counter=images.paginator.count %}
                There is {{ counter }} match
            {% plural %}
                There are {{ counter }} matches
            {% endblocktrans %}
        </h2>

        {% search_other %}
    {% endif %}

    {# Used below for the checkbox aria_labelledby #}
    <p class="visuallyhidden" id="select-image-label">{% trans "Select image" %}</p>

    <ul class="listing horiz images">
        {% for image in images %}
            <li>
                {% include "wagtailadmin/bulk_actions/listing_checkbox_cell.html" with obj_type="image" obj=image aria_labelledby_prefix="select-image-label image_" aria_labelledby=image.pk|unlocalize aria_labelledby_suffix="_title" %}
                <a class="image-choice" title="{% if collections %}{{ image.collection.name }} » {% endif %}{{ image.title }}" href="{% url 'wagtailimages:edit' image.id %}{% if next %}?next={{ next|urlencode }}{% endif %}">
                    <figure>
                        {% include "wagtailimages/images/results_image.html" %}
                        {% trans "pixels" as translated_pixels %}
                        <figcaption id="image_{{ image.pk|unlocalize }}_title">
                            {{ image.title|ellipsistrim:60 }}
                            <span class="visuallyhidden">{{ image.width }} {{ translated_pixels  }} &#215; {{ image.height }} {{ translated_pixels}}</span>
                        </figcaption>
                    </figure>
                </a>
            </li>
        {% endfor %}
    </ul>

    {% include "wagtailadmin/shared/pagination_nav.html" with items=images %}

{% else %}
    {% if is_searching %}
        <h2 role="alert">{% blocktrans trimmed %}Sorry, no images match "<em>{{ query_string }}</em>"{% endblocktrans %}</h2>

        {% search_other %}
    {% else %}
        {% url 'wagtailimages:add_multiple' as wagtailimages_add_image_url %}
        {% if current_collection %}
            <p>{% blocktrans trimmed %}You haven't uploaded any images in this collection. Why not <a href="{{ wagtailimages_add_image_url }}">upload one now</a>?{% endblocktrans %}</p>
        {% else %}
            <p>{% blocktrans trimmed %}You haven't uploaded any images. Why not <a href="{{ wagtailimages_add_image_url }}">upload one now</a>?{% endblocktrans %}</p>
        {% endif %}
    {% endif %}
{% endif %}
